<?php
session_start();
if($_SESSION['userid']!=null) {
	echo '<script>window.location="home.php"</script>';
	die();
}
?>

<!DOCTYPE html>
<html lang="en" >
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>学生请假系统</title>
	<link rel="stylesheet" type="text/css" href="common.css">
	<script type="text/javascript">
	function call_login(){
    var xmlHttp;
    var str;
    try{
    	xmlHttp=new XMLHttpRequest();
    }
 	catch(e){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.onreadystatechange=function(){
    	if (xmlHttp.readyState==4){	
    		if (xmlHttp.status==200){  
    			str = xmlHttp.responseText;  
    			if(str=="yes"){
    				window.location="home.php";
    				return;
    			}
    			document.getElementById("login-error").innerHTML = str; 
    		}else{
    			alert("系统错误,如有疑问,请与管理员联系!"+xmlHttp.status);
    		}
    	}
	}
	var userid = document.getElementById("user-input").value;
	var pwd = document.getElementById("pwd-input").value;
	var url = "userid=" + userid + "&pwd=" +pwd ;
 	xmlHttp.open("POST","login_check.php",true);
 	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 	xmlHttp.send(url); 
 	}
	</script>
</head>
<body>
	<div id="login-head"><img src="img/scnulogo.png"><br>学生请假系统(班长版)</div>
	<div id="wrapper">
		<form id="user-login" method="post" onsubmit="return false;">
			<h2><img id="login-logo" src="img/login.png">用户登录</h2>
			<hr>
			<p>
				<label>学号<input type="text" id="user-input" name="userid"></label>
			</p>
			<p>
				<label>密码<input type="password" id="pwd-input" name="pwd"></label>
			</p>
			<hr>
			<p>
				<input value="登录" type="submit" onclick="call_login();">
				<span id="login-error"></span>
			</p>
		</form>
	</div>
</body>
</html>